<?php
    $link = mysql_connect('mysql12.freehostia.com', 'davmor88_aleydei', 'Admin123');
    mysql_select_db('davmor88_aleydei');
    mysql_query("SET NAMES utf8");
    mysql_query("SET CHARACTER SET utf8");
    
    /*$link = mysql_connect('localhost', 'root', 'Admin123');
    mysql_select_db('aleydei');
    mysql_query("SET NAMES utf8");
    mysql_query("SET CHARACTER SET utf8");*/
    
    $qry = "Select * From invitados Where desconfirm = 0 Order By descripcion ASC";
    $r = mysql_query($qry);
    
    $pages = mysql_num_rows($r)/33;
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<META HTTP-EQUIV="PRAGMA" CONTENT="NO-CACHE">
<META HTTP-EQUIV="CACHE-CONTROL" CONTENT="NO-CACHE">
<title>Ale y Dei - Lista de Invitados </title>
<link rel="shortcut icon" href="../img/ico.png" type="image/png">
<link rel="stylesheet" href="../css/styles.css">
<script src="../js/jquery-1.7.1.js"></script>

<script>
	$(document).ready(function(){
		$("input:checkbox").change(function(){
			$.post("ucan.php",{"val":$(this).is(":checked"), "code":$(this).val()});
			if($(this).is(":checked")){
				$(this).closest("tr").css("color","red");
			}else{
				$(this).closest("tr").css("color","#000000");
			}
		});
	});
</script>
<style media="all">
    
    body{
        margin-left: auto;
        margin-right: auto;
        -webkit-print-color-adjust: exact;
    }
    
    h1{
        font-family: "Century Gothic";
        font-size: 20px;
    }
    
    table.contenido{
        margin-left: 25px; 
        margin-top: 5px; 
        page-break-after: always;
    }
    
    table.end{
        margin-left: 25px; 
        margin-top: 5px;
    }
    
    th{
        padding-left: 10px;
        padding-right: 10px;
        padding-top: 5px;
        padding-bottom: 5px;
        font-family: Arial;
        font-size: 13px;
        color: #FFFFFF;
        background-color: #2A2A2B;
        border-right: 1px solid #ffffff;
    }
    
    td{
        padding-left: 10px;
        padding-right: 15px;
        padding-top: 3px;
        padding-bottom: 3px;
        font-family: "Century Gothic";
        font-size: 12px;
        border-right: 1px solid #000000;
    }
    
    td.left{
        border-left: 1px solid #000000;
    }
</style>
</head>
<body>
    <?php 
    $p = 0;
    $tinvi = 0;
    $tconf = 0;
    while($p < $pages){ 
        $p++; 
        if($p>$pages){
            $clstbl = "end";
        }else{
            $clstbl = "contenido";
        }?>
    <img src="../img/hdr.jpg" height="87px" width="640px" style="padding-top: 10px;"/>
    <h1 style="margin-left: 20px;">Listado de invitados.</h1>
    <table cellpadding="0" cellspacing="0" class="<?php echo $clstbl; ?>">
        <thead>
            <tr>
                <th style="width: 70px; border-left: 1px solid #000000;">Codigo</th>
                <th style="width: 300px;">Invitados</th>
                <th style="width: 70px;">No.<br/>Invitados</th>
                <th style="width: 100px;">No. Mesa</th>
                <!--th style="width: 40px; border-right: 1px solid #000000;">Canc.</th-->
            </tr>
        </thead>
        <tbody>
        <?php 
        $tsinvi = 0;
        $tsconf = 0;
        $cont = 0;
        while($cont < 33){
            $rec = mysql_fetch_assoc($r);
            if(!$rec){
                break;
            }
            if(($cont % 2)==0){
                $back = "#FFFF64";
            }else{
                $back = "#FFCE64";
            }?>
            <tr style="background-color: <?php echo $back; ?>;">
                <td class="left" align="center" <?php echo $cont == 32 ? "style='border-bottom: 1px solid #000;'" : ""; ?>><?php echo $rec['code']; ?></td>
                <td <?php echo $cont == 32 ? "style='border-bottom: 1px solid #000;'" : ""; ?>><?php echo $rec['descripcion']; ?></td>
                <td align="right" <?php echo $cont == 32 ? "style='border-bottom: 1px solid #000;'" : ""; ?>><?php echo $rec['confirm']; ?></td>
                <td align="right" <?php echo $cont == 32 ? "style='border-bottom: 1px solid #000;'" : ""; ?>><?php echo $rec['mesa']; ?></td>
            </tr>
        <?php
        if($rec['desconfirm'] == 0){
            $tconf += $rec['confirm'];
		}
            $cont++;
        }?>    
        </tbody>
    </table>
    <?php } 
    mysql_free_result($r);?>
    <table cellpadding="0" cellspacing="0" class="end">
        <tfoot>
            <tr>
                <th style="width: 70px; border-left: 1px solid #000000; border-top: 1px solid #ffffff;">Total:</th>
                <th style="width: 300px; border-top: 1px solid #ffffff;"></th>
                <th style="width: 70px; border-top: 1px solid #ffffff;"><?php echo $tconf; ?></th>
                <th style="width: 100px; border-top: 1px solid #ffffff;"></th>
            </tr>
        </tfoot>
    </table>
</body>
</html>